
<style type="text/css">
#orderGoodsDiv{margin-top:10px;}
#orderGoodsDiv table{width:100%; text-align:left; clear:both;}
#orderGoodsDiv table th, #orderGoodsDiv table td{padding:5px; text-align:left; vertical-align:top;
	background:#f3f3f3;}
#orderGoodsDiv table td .goodThumbDiv, #orderGoodsDiv table td .goodThumbDiv a{float:left; width:80px; height: 80px;}
#orderGoodsDiv table td .goodTitleAttrDiv{float:left; height: 80px;}
#orderGoodsDiv table td p.goodTitle{padding:5px;}
#orderGoodsDiv table td p.goodAttr{padding:5px; color:#999;}
#orderGoodsDiv table #orderTotalTd{text-align:right;}
#orderGoodsDiv table #orderTotalTd p{text-align:right;}
#orderGoodsDiv table #orderTotal{color:#F30;}
</style>

<div class="current_location">
    <ul>
        <li><a>当前位置：</a></li>
        <li><a>订单管理</a></li>
        <li> > <a>编辑订单</a></li>
    </ul>
</div>

<form id="order_info_form" method="post" action="<?php echo $view_data['save_url']; ?>"  onsubmit="return save_order_info();">

    <?php if(!empty($view_data['order_info'])): ?>
    <input type="hidden" name="id" value="<?php echo $view_data['order_info']['id']; ?>" />
    <?php endif ?>

    <div class="form_content">
        <div class="unit">
            <label>订单编号：</label>
            <span><?php echo $view_data['order_info']['order_sn']; ?></span>
        </div>

        <div class="unit">
            <label>订单状态：</label>
            <span><?php echo $view_data['order_info']['status_desc']; ?></span>
        </div>

        <div class="unit">
            <label>下单时间：</label>
            <span><?php echo $view_data['order_info']['create_time_date_time']; ?></span>
        </div>

        <div class="unit">
            <label>收货地址：</label>
            <?php echo $view_data['order_info']['province_name']; ?> <?php echo $view_data['order_info']['city_name']; ?> <?php echo $view_data['order_info']['district_name']; ?> <?php echo $view_data['order_info']['street_name']; ?> <?php echo $view_data['order_info']['address']; ?>
            <span><?php echo $view_data['order_info']['receiver']; ?></span>
            <span><?php echo $view_data['order_info']['mobile']; ?></span>
            <span><?php echo $view_data['order_info']['tel']; ?></span>
        </div>

        <?php if(in_array( $view_data['order_info']['status'], array(1, 2, 3, -2) )): ?>
        <div class="unit">
            <label>配送方式：</label>
            <span>
                <select name="shipping_id">
                    <?php foreach ($view_data['business_config']['shipping_look_up'] as $shipping_id => $shipping_name): ?>
                    <option value="<?php echo $shipping_id; ?>" <?php if((!empty($view_data['order_info']['shipping_id'])) && $view_data['order_info']['shipping_id'] == $shipping_id): ?>selected="selected"<?php endif; ?>><?php echo $shipping_name; ?></option>
                    <?php endforeach; ?>
                </select>
            </span>
            <span>单号：<input type="text" name="shipping_sn" value="<?php if(!empty($view_data['order_info']['shipping_sn'])): echo $view_data['order_info']['shipping_sn']; endif; ?>" maxlength="100" /></span>

            <?php if( in_array($view_data['order_info']['status'], array(2,3)) ) : ?>
            <span><a href="https://www.kuaidi100.com/chaxun?com=<?php echo $view_data['business_config']['shipping_code_look_up'][$view_data['order_info']['shipping_id']]; ?>&nu=<?php echo $view_data['order_info']['shipping_sn']; ?>" target="_blank">追踪快递</a></span>
            <?php endif; ?>
        </div>
        <?php endif ?>

        <?php if(!empty($view_data['order_info']['pay_time'])) : ?>
            <div class="unit">
                <label>付款时间：</label>
                <span><?php echo $view_data['order_info']['pay_time_date_time']; ?></span>
            </div>
        <?php endif ?>

        <?php if(!empty($view_data['order_info']['shipping_time'])) : ?>
            <div class="unit">
                <label>发货时间：</label>
                <span><?php echo $view_data['order_info']['shipping_time_date_time']; ?></span>
            </div>
        <?php endif ?>

        <?php if(!empty($view_data['order_info']['confirm_receive_time'])) : ?>
        <div class="unit">
            <label>收货时间：</label>
            <span><?php echo $view_data['order_info']['confirm_receive_time_date_time']; ?></span>
        </div>
        <?php endif ?>

        <?php if(!empty($view_data['order_info']['confirm_return_time'])) : ?>
            <div class="unit">
                <label>退货时间：</label>
                <span><?php echo $view_data['order_info']['confirm_return_time_date_time']; ?></span>
            </div>
        <?php endif ?>

        <div id="orderGoodsDiv">
            <table>
                <thead>
                    <tr>
                        <th>商品</th>
                        <th>价格</th>
                        <th>数量</th>
                        <th>小计</th>
                    </tr>
                </thead>

                <tbody>
                    <?php foreach ($view_data['order_good_list'] as $item): ?>
                    <tr>
                        <td>
                            <div class="goodThumbDiv">
                                <a title="<?php echo $item['good_name']; ?>" target="_blank" href="<?php echo $this->get_url(array('route' => 'good_info', 'id' => $item['good_id']), true); ?>">
                                    <img class="goodThumb" height="80" width="80" alt="<?php echo $item['good_name']; ?>" src="<?php echo $item['good_thumb']; ?>">
                                </a>
                            </div>
                            <div class="goodTitleAttrDiv">
                                <p class="goodTitle"><a href="<?php echo $this->get_url(array('route' => 'good_info', 'id' => $item['good_id']), true); ?>" target="_blank" ><?php echo $item['good_name']; ?></a></p>
                                <p class="goodAttr"><?php echo $item['spec_desc']; ?></p>
                            </div>
                        </td>
                        <td><?php echo $item['good_price']; ?></td>
                        <td><?php echo $item['good_number']; ?></td>
                        <td><?php echo $item['item_total_price']; ?></td>
                    </tr>
                    <?php endforeach; ?>

                    <tr>
                        <td id="orderTotalTd" colspan="4">
                            <p>共 <span id="orderTotal">￥ <?php echo $view_data['order_info']['order_total_price']; ?></span></p>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>




        <?php if(in_array( $view_data['order_info']['status'], array(1, 2, 3, -2) )): ?>
        <div class="unit">
            <label></label>
            <input class="input_submit" type="submit" value="提交" />
        </div>
        <?php endif ?>
    </div>
</form>

<script type="text/javascript">
    function save_order_info(){
        $.ajax({
            type: 'POST',
            url: "<?php echo $view_data['save_url']; ?>",
            data: $('#order_info_form').serialize(),
            dataType: 'json',
            success: function(rdata){
                if(rdata.status <= 0){
                    alert(rdata.message);
                }else{
                    alert(rdata.message);
                    window.top.location.reload();
                }

                return false;
            }
        });

        return false;
    }
</script>